package com.liohi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liohi.entity.RoleMenu;
import com.liohi.entity.UserRole;
import com.liohi.service.RoleMenuService;
import com.liohi.mapper.RoleMenuMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author liohi
* @description 针对表【role_menu】的数据库操作Service实现
* @createDate 2023-08-02 15:43:06
*/
@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu>
    implements RoleMenuService{

    @Override
    public List<Integer> getMenuIdsByRoleIds(List<Integer> roleIds) {
        List<Integer> res = new ArrayList<>();
        QueryWrapper<RoleMenu> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("role_id", roleIds);
        List<RoleMenu> roleMenus = this.list(queryWrapper);

        for (RoleMenu roleMenu : roleMenus) {
            res.add(roleMenu.getMenuId());
        }
        return res;
    }
}




